package com.niit.spark.sql.test

import org.apache.spark.sql.functions.desc
import org.apache.spark.sql.{DataFrame, SparkSession}

/**
 * Date:2025/5/16
 * Author：Ys
 * Description:
 */
object SortBySalary {

  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession.builder().appName("SortBySalary").master("local[*]").getOrCreate()
    spark.sparkContext.setLogLevel("ERROR")
    import spark.implicits._
    val df: DataFrame = spark.read.option("header", "true").csv("input/sql/employees.csv")
    //对工资列进行降序排序
    df.sort(desc("salary")).show() //默认是升序 AES  降序DESC

    spark.stop()

  }

}
